extension StringKeyMix on String {
  static const Map<String, String> hxm = {};

  static Map<String, String>? _reHxMap;

  static Map<String, String> get reHxMap {
    if (_reHxMap == null) {
      _reHxMap = {};
      for (String key in hxm.keys) {
        _reHxMap![hxm[key]!] = key;
      }
    }
    return _reHxMap!;
  }

  String get hx => hxm[this] ?? this;

  static var separator = "_";
  static List<String> keys = hxm.keys.toList();
  String get rhx {
    if (!contains(separator)) return this;
    List<String> values = split(separator);
    var i = int.parse(values[0]);
    String v = values[i];
    return v;
  }

  static Map jsonConvertMapHx(Map data) {
    Map<String, dynamic> newData = {};
    for (dynamic d in data.keys) {
      var key = reHxMap[d] ?? d;
      var value = data[d];
      if (value is Map) {
        newData[key] = jsonConvertMapHx(value);
      } else if (value is List) {
        newData[key] = jsonConvertListHx(value);
      } else {
        newData[key] = value;
      }
    }
    return newData;
  }

  static List jsonConvertListHx(List list) {
    List l = [];
    for (dynamic m in list) {
      if (m is Map) {
        l.add(jsonConvertMapHx(m));
      } else if (m is List) {
        l.add(jsonConvertListHx(m));
      } else {
        l.add(m);
      }
    }
    return l;
  }
}
